DSP First Laboratory Exercise #10 The z, n, and ˆω Domains 1 Objective The objective for this lab is to build an intuitive understanding of the relationship between the location of poles and zeros in the z-domain, the impulse response h[n] in the ndomain, and the frequency response H(e j ˆω ) (the ˆω domain). A graphical user interface (GUI) called pez was written in Matlab for doing interactive explorations of the three domains. 1 2 Warm-up Invoke pez by simply typing pez at the Matlab prompt, if you have the DSP First Toolbox installed. A control panel with a few buttons and a plot of the unit circle in the complex z-plane will pop up. You can use the controller to selectively place poles and zeros in the z-plane, and then observe how their placement affects the impulse and frequency responses. If the plots need manual updating, click on the Redo Plots button under <Quicksize...> menu. The Real Time Drag Plots button will put pez in a mode such that an individual pole/zero (pair) can be moved around and the corresponding H(e j ˆω ) and h[n] plots will be updated. Since exact placement of poles and zeros with the mouse is difficult, an Edit By Co-Ord button is provided for numerical entry of the real and imaginary parts, or magnitude and angle (a separate edit window will appear when you use this option). Before you can edit a pole or zero, however, you must first select it with the mouse. Removal of individual poles or zeros can also be performed by clicking on the Delete Poles & Zeros (again, a separate window will appear). Note that all poles and/or zeros can be easily cleared by clicking on the <Clear...> menu, and then selecting Poles, Zeros, orall. Play around with pez for a few minutes to gain some familiarity with the interface. Try implementing a 3-point averager by placing its zeros (and poles) at the correct location in the z-plane. Instructor Verification (separate page) PEZ CD-ROM 3 Laboratory: Relationships between z, n, and ˆω domains Work through the following exercises and keep track of your observations by filling in the worksheet at the end of this assignment. In general, you want to make note of the following quantities: How does h[n] change with respect to oscillation period and rate of decay? How does H(e j ˆω ) change with respect to peak location and width. 4 Real Poles (a) Use pez to place a pole at z = 1 2. You may have to use the Edit by Co-Ord button to get the location exactly right. Use the plots for this case as the reference for answering the next 1 pez was written by Craig Ulmer. CD-ROM Instructor Verification Sheet 1
four parts. (b) Move the pole close to the origin (still on the real axis). You can do this by clicking on the pole and dragging it to the new location. Describe the changes in the impulse response h[n] and the frequency response H(e j ˆω ). (c) You can also move poles and zeros under the influence of the Real Time Drag Plots option in pez. When this box is checked, the impulse response and frequency response plots are updated while you move the pole (or zero). Once this mode is set, click on the pole you want to move and start to drag it slowly. Watch for the update of the plots in the secondary window. After the real-time updating has started, you can release the mouse button and the pole (or zero) will follow the cursor. Click on the pole once more to stop moving it and to stop the updating. It is sometimes a little tricky to use. Also the display may be jerky unless you have a high-performance computer with fast graphics. Move the real pole slowly from z = 1 2 to z = 1 and observe the changes in the impulse response h[n] and the frequency response H(e j ˆω ). (d) Place the pole exactly on the unit circle. Describe the changes in h[n] and H(e j ˆω ). (e) Move the pole outside the unit circle. Describe the changes in h[n] and H(e j ˆω ). (f) In general, where should poles be placed to guarantee system stability? By stability we mean that the system s output does not blow up. 5 Complex Poles If the denominator polynomial A(z) has a complex root, it will have a second root at the conjugate location when the polynomial coefficients are real. For example, if we place a root at z = 1 3 + j 1 2, then we will also get one at z = 1 3 j 1 2. (a) What property of the polynomial coefficients of A(z) =1+a 1 z 1 +a 2 z 2 will guarantee that the roots come in conjugate pairs? (b) Clear all the poles and zeros from pez. Now place a pole with magnitude 0.75 at an angle of 45 ; and then two zeros at the origin. Note that pez automatically places a conjugate pole in the z-domain. (c) Derive the filter coefficients for the denominator A(z) and numerator B(z) =b 0 +b 1 z 1 + b 2 z 2. Use the following relationship: B(z) A(z) = G (1 z 1z 1 )(1 z 2 z 1 ) (1 p 1 z 1 )(1 p 2 z 1 ) (1) where z 1 and z 2 are the zeros, and p 1 and p 2 are the poles from part (b). (Remember that Matlab can multiply polynomials via its conv function.) Record the filter coefficients for later use. (d) Change the angle of the pole: move the pole to 90, then 135. Describe the changes in h[n] and H(e j ˆω ). (e) Increase the magnitude of the pole: first try 0.9, then 0.95, and then go outside the unit circle. Describe the changes in h[n] and H(e j ˆω ). 2
2 (a) FIR Filter 6 (b) Feedback Filter magnitude 1.5 1 0.5 magnitude 4 2 0-1 0 1 omega/pi 0-1 0 1 omega/pi Figure 1: Magnitude response of two unknown filters. Use pez to help you find the filter coefficients that will match these frequency responses as closely as possible. (a) Second-order FIR filter. (b) Second-order IIR filter. 6 Filter Design In this section, we will use pez to place the poles and zeros to make a filter with a desirable frequency response. First of all, we will put poles at the origin and zeros on the unit circle to gain some understanding of these special cases. (a) Clear all the poles and zeros from pez. Now place a single pole at z = 0 and observe the impulse and frequency response. Now place another pole at the origin and observe carefully the changes in h[n] and the magnitude and phase of H(e j ˆω ). Finally, place a third pole at z = 0. What can you conclude about the effect of poles at the origin on the impulse response, magnitude response and phase response of a system? (b) Clear all poles and zeros from pez. Now place zeros at the following locations: z 1 = 1, z 2 =0 jand z 3 =0+j(remember that conjugate pairs such as z 2 and z 3 will be entered simultaneously). Judging from the impulse and frequency responses what type of filter have you just implemented? Measure (as best you can) the slope of the phase response. Design of a filter involves selecting the coefficients {a k } and {b k } to accomplish a given task. The task here is to create a filter that has a very narrow notch. This filter would be useful for removing one frequency component while leaving others undisturbed. The notch filter can be synthesized from the cascade of two simpler filters shown in Fig. 1. (c) Start the process by using pez to design each of the filters given in Fig. 1. Both filters are second-order. Make sure that you enter the poles and zeros precisely. pez will do the conversion between between root locations and polynomial coefficients, but you could also do this with the Matlab commands roots and poly. You should check your results by also calculating the filter coefficients by hand. Record the coefficients of your filters in the table provided. (d) Use freqz() to verify that the frequency response of each filter is correct. 3
(e) Now use pez to put the filters together in a cascade. Place the poles and zeros, and then view the frequency response. What are the filter coefficients for the cascaded filter H(z)? (f) Use freqz() to determine the frequency response of the cascade of the two filters that you designed in part (e). Plot the magnitude of the overall frequency response of the cascade system for 1 2 < ˆω/(2π) < 1 2, and print a copy of the plot for your lab report. Explain briefly why the frequency response magnitude has a notch, and explain why the gain at ˆω = 0 and ˆω = π is the same. 4
Worksheet for Observations Name: Date: Implemented 3-pt averager with pez: Part Observations 4(a) h[n] decays exponentially with no oscillations, H(e j ˆω ) has a hump at ˆω =0 4(b) 4(c) 4(d) 4(e) 4(f) 5(a) 5(b) 5(c) 5(d) 6(a) 6(b) Part 6(c,d,e,f) a k b k Filter 1 Filter 2 Cascade of 1 and 2 Explanation of cascade frequency response: 5